package jumpingnotes.model.entity;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name = "record_task", catalog = "jumping_notes")
public class RecordTask implements java.io.Serializable
{

	private Integer recordTaskId;
	private RecordAlbum recordAlbum;
	private Chapter chapter;
	private Integer memberId;
	private Integer status;
	private Integer latestAudioId;
	private Integer publishedAudioId;
	private Integer ratingTotal;
	private Integer ratingCount;
	private Integer playCount;
	private Date createTime;
	private Date updateTime;
	private Set<Audio> audios = new HashSet<Audio>(0);

	public RecordTask()
	{
	}

	public RecordTask(RecordAlbum recordAlbum, Chapter chapter)
	{
		this.recordAlbum = recordAlbum;
		this.chapter = chapter;
	}

	public RecordTask(RecordAlbum recordAlbum, Chapter chapter, Integer status, Integer latestAudioId,
			Integer publishedAudioId, Integer ratingTotal, Integer ratingCount, Integer playCount, Date createTime,
			Date updateTime, Set<Audio> audios)
	{
		this.recordAlbum = recordAlbum;
		this.chapter = chapter;
		this.status = status;
		this.latestAudioId = latestAudioId;
		this.publishedAudioId = publishedAudioId;
		this.ratingTotal = ratingTotal;
		this.ratingCount = ratingCount;
		this.playCount = playCount;
		this.createTime = createTime;
		this.updateTime = updateTime;
		this.audios = audios;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "record_task_id", unique = true, nullable = false)
	public Integer getRecordTaskId()
	{
		return this.recordTaskId;
	}

	public void setRecordTaskId(Integer recordTaskId)
	{
		this.recordTaskId = recordTaskId;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "record_album_id", nullable = false)
	public RecordAlbum getRecordAlbum()
	{
		return this.recordAlbum;
	}

	public void setRecordAlbum(RecordAlbum recordAlbum)
	{
		this.recordAlbum = recordAlbum;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "chapter_id", nullable = false)
	public Chapter getChapter()
	{
		return this.chapter;
	}

	public void setChapter(Chapter chapter)
	{
		this.chapter = chapter;
	}

	@Column(name = "member_id")
	public Integer getMemberId()
	{
		return this.memberId;
	}

	public void setMemberId(Integer memberId)
	{
		this.memberId = memberId;
	}

	@Column(name = "status")
	public Integer getStatus()
	{
		return this.status;
	}

	public void setStatus(Integer status)
	{
		this.status = status;
	}

	@Column(name = "latest_audio_id")
	public Integer getLatestAudioId()
	{
		return this.latestAudioId;
	}

	public void setLatestAudioId(Integer latestAudioId)
	{
		this.latestAudioId = latestAudioId;
	}

	@Column(name = "published_audio_id")
	public Integer getPublishedAudioId()
	{
		return this.publishedAudioId;
	}

	public void setPublishedAudioId(Integer publishedAudioId)
	{
		this.publishedAudioId = publishedAudioId;
	}

	@Column(name = "rating_total")
	public Integer getRatingTotal()
	{
		return this.ratingTotal;
	}

	public void setRatingTotal(Integer ratingTotal)
	{
		this.ratingTotal = ratingTotal;
	}

	@Column(name = "rating_count")
	public Integer getRatingCount()
	{
		return this.ratingCount;
	}

	public void setRatingCount(Integer ratingCount)
	{
		this.ratingCount = ratingCount;
	}

	@Column(name = "play_count")
	public Integer getPlayCount()
	{
		return this.playCount;
	}

	public void setPlayCount(Integer playCount)
	{
		this.playCount = playCount;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "create_time", length = 19)
	public Date getCreateTime()
	{
		return this.createTime;
	}

	public void setCreateTime(Date createTime)
	{
		this.createTime = createTime;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "update_time", length = 19)
	public Date getUpdateTime()
	{
		return this.updateTime;
	}

	public void setUpdateTime(Date updateTime)
	{
		this.updateTime = updateTime;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "recordTask")
	public Set<Audio> getAudios()
	{
		return this.audios;
	}

	public void setAudios(Set<Audio> audios)
	{
		this.audios = audios;
	}

}
